# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>

pkgname=libsigrok
pkgver=0.5.2
pkgrel=0
pkgdesc="A C library providing access to logic analyzers and related file formats"
url="https://sigrok.org/wiki/Libsigrok"
makedepends="libzip-dev glib-dev libserialport-dev libusb-dev libftdi1-dev
	glibmm-dev check-dev doxygen"
arch="all"
license="GPL-3.0-only"
source="http://sigrok.org/download/source/libsigrok/libsigrok-$pkgver.tar.gz"
subpackages="$pkgname-dev"
# Check fails in virtual environment (e.g. on the Alpine LXC build containers),
# as libusb requires /dev/bus/usb be present/usable to be initialized. The
# unit tests pass on a real hardware
options="!check"

prepare() {
	default_prepare
	sed -e "s|^Version:.*|Version: $pkgver|g" \
		-i libsigrok.pc.in \
		-i bindings/cxx/libsigrokcxx.pc.in
}

build() {
	./configure --prefix=/usr --disable-static
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir/lib/udev/rules.d"
	cp contrib/60-libsigrok.rules "$pkgdir/lib/udev/rules.d/60-libsigrok.rules"
	cp contrib/61-libsigrok-plugdev.rules "$pkgdir/lib/udev/rules.d/60-libsigrok.rules"
}

sha512sums="cf673dad6280302d69050c29490621f66c6d6a73932d019a53ec3501316d3f2e23e7667a04f866dbe6ed73f86a63de73d2173e2b6cea563631d705e06f887092  libsigrok-0.5.2.tar.gz"
